import request from "../utils/request";

// 接口返回结构固定
// data 的类型, 传进来
type Result<T = undefined> = {
    code: string,
    message: string,
    data: T
}


//  登入
export function login(loginname: string, password: string) {
    return request.post<
        any,
        Result<{ token: string, userid: string }>
    >('/user/login', {
        loginname,
        password
    })
}


// 判断是否注册
export function ifcell(tel: string) {
    return request.post<any, Result>('/user/docheckphone', {
        tel
    })
}

//  获取短信
export function cell(tel: string) {
    return request.post<any, Result>('/user/dosendmsgcode', {
        tel,
    })
}

//  判断验证码
export function iftelcode(tel: string, telcode: string) {
    return request.post<any, Result>('/user/docheckcode', {
        tel,
        telcode,
    })
}


//  注册
export function sign(tel: string, password: string) {
    return request.post<any, Result>('/user/dofinishregister', {
        tel,
        password,
    })
}


//获取用户信息


export function info(userid: string) {
    return request.get<any, Result>('/user/info', {
        params: {
            userid
        }
    })
}


